require'headers.main_headers'

-- open main window
MOAISim.openWindow( GAME_NAME, SCREEN_RESOLUTION_X, SCREEN_RESOLUTION_Y )
MOAISim.setHistogramEnabled(true)
--io.output():setvbuff("no")

-- setup viewport
-- entire window
viewport = MOAIViewport.new ()
viewport:setSize( SCREEN_RESOLUTION_X, SCREEN_RESOLUTION_Y )
viewport:setScale( WORLD_RESOLUTION_X, WORLD_RESOLUTION_Y )

g_viewport = MOAIViewport.new()
g_viewport:setSize( 
		SCREEN_RESOLUTION_X-SCREEN_RESOLUTION_X*0.125, 
		SCREEN_RESOLUTION_Y-SCREEN_RESOLUTION_Y*0.125)
g_viewport:setScale ( WORLD_RESOLUTION_X, -WORLD_RESOLUTION_Y )
g_viewport:setOffset(-0.885, 0.885)

-- turns off texture loading console messages
MOAILogMgr.setLogLevel(MOAILogMgr.LOG_NONE)


function mainLoop()
	
	Game:start()

end
ThreadManager:initialize()
gameThread = MOAICoroutine.new()
gameThread:run ( mainLoop )



--[====[
-- create layer and assign to viewport
layer = MOAILayer2D.new()
layer:setViewport( viewport )

-- store defintion of tile back
ResourceDefinitions:set( 'tile_back', tileBackDef )

-- creation of our deck
imageDeck = ResourceManager:get( 'tile_back' )
--[[ old but kept for reference

imageGfx = MOAIGfxQuad2D.new ()
imageGfx:setTexture( 'assets/tile_back.png' )
imageGfx:setRect(-31, -31, 31, 31 )

]]

-- define prop
imageProp = MOAIProp2D.new ()
-- tell prop to use imageGfx as the deck
imageProp:setDeck (imageDeck)
-- move prop to center of screen
imageProp:setLoc( 0, 0 )
-- insert prop into layer
layer:insertProp(imageProp)
-- make layer renderable
renderTable = { layer }
MOAIRenderMgr.setRenderTable(renderTable)

]====]
